package com.hualude.roadsign.controller;

import com.hualude.roadsign.dto.DTRequestDto;
import com.hualude.roadsign.dto.DTResponseDto;
import com.hualude.roadsign.dto.JsonMsgDto;
import com.hualude.roadsign.service.SolarEnergyHandleService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by ding on 2017/7/12.
 */
@Controller
@RequestMapping("/rds_solarEnergyHandle")
public class SolarEnergyHandleController {

    @Resource
    private SolarEnergyHandleService solarEnergyHandleService;

    @RequestMapping(value = "/getSolarHandle4DT")
    @ResponseBody
    public DTResponseDto getSolarHandle4DT(DTRequestDto dtRequestDto, String actorIds , Integer orgId,Integer solarMaintenanceStatus) {
        DTResponseDto dtResponseDto = new DTResponseDto();
        try {
            dtResponseDto = solarEnergyHandleService.getSolarHandle4DT(dtRequestDto,actorIds, orgId,solarMaintenanceStatus);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dtResponseDto;
    }

    @RequestMapping("/addSolarMaintenanceContent")
    @ResponseBody
    public JsonMsgDto addSolarMaintenanceContent(Integer solarFaultId, String solarMaintenanceContent) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(solarEnergyHandleService.addSolarMaintenanceContent(solarFaultId, solarMaintenanceContent));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);

        }
        return jsonMsgDto;
    }

    @RequestMapping("/getSolarMaintainer")
    @ResponseBody
    public JsonMsgDto getSolarMaintainer(Integer solarOrgId) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(solarEnergyHandleService.getSolarMaintainer(solarOrgId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);

        }
        return jsonMsgDto;
    }

    @RequestMapping("/finishSolarMaintenance")
    @ResponseBody
    public JsonMsgDto finishSolarMaintenance(String solarMaintenancePhoto,Integer solarMaintainerId,String solarMaintenanceTime,String solarMaintenanceExplain,Integer solarFaultId) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(solarEnergyHandleService.finishSolarMaintenance(solarMaintenancePhoto,solarMaintainerId,solarMaintenanceTime,solarMaintenanceExplain,solarFaultId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);

        }
        return jsonMsgDto;
    }

    @RequestMapping("/getSolarFaultHandleList4App")
    @ResponseBody
    public JsonMsgDto getSolarFaultHandleList4App(Integer orgId,Integer maintenanceStatus,String actorIds,Integer count,Integer size) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(solarEnergyHandleService.getSolarFaultHandleList4App(orgId, maintenanceStatus, actorIds, count, size));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);

        }
        return jsonMsgDto;
    }

    @RequestMapping("/getReceiptInfo4App")
    @ResponseBody
    public JsonMsgDto getReceiptInfo4App(Integer solarFaultId) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(solarEnergyHandleService.getReceiptInfo4App(solarFaultId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);

        }
        return jsonMsgDto;
    }
}
